<!-- Teacher_TrainListFrame.html -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>培训frame</title>
    <link rel="stylesheet" href="../../css/api.css" />
	<link rel="stylesheet" href="../../css/mui.min.css"/>
	<link rel="stylesheet" href="../../css/base.css"/>
	<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
	<style type="text/css">
		.train-dongtai-content{
			padding: 10px 0;
			background-color: white;
		}
		.train-tag{
			border-left: 2px solid #18b4ed;
			height: 40px;
			padding: 10px;
			background-color: #f0f0f0;
		}
		.train-dongtai-content .train-tag .train-more{
			float: right;
		}
		.train-more{
			float: right;
		}
		.train-dongtai-content .cell-right-div{
			width: 80px;
			float: right;
			text-align: right;
			line-height: 20px;
		}
		.train-dongtai-content .cell-left-div{
			margin-right: 80px;
			white-space: nowrap;
			word-break: keep-all;
			overflow: hidden;
			text-overflow: ellipsis;
			line-height: 20px;
		}
		.new-train-content{
			background-color: white;
		}
		.new-train-content .segment-content{
			padding: 0 40px;
		}
		.mui-table-view-cell>a:not(.mui-btn){
			padding: 10px;
		}
		.mui-table-view-cell>a:not(.mui-btn) .course-img{
			display:block;
			width: 136px;
			max-width: 136px;
			height: 84px;
			background-image: url(../../image/course_placehoder.png);
			background-size: 136px 84px;
			display: block;
		    object-fit: cover;
		}
		.mui-table-view-cell .top-content{
			/*height: 40px;*/
		}
		.mui-table-view-cell .bottom-content{
			padding-top: 16px;
			/*height: 40px;*/
		}
		.mui-table-view-cell>a:not(.mui-btn) .course_title{
			overflow: hidden;
		 	text-overflow: ellipsis;
		 	white-space: pre-wrap;
		 	display: -webkit-box;
		 	-webkit-line-clamp: 2;
		 	-webkit-box-orient: vertical;
		 	font-size: 16px;
		 	color: #666666;
		 	line-height: 20px;
		}
		.mui-table-view-cell>a:not(.mui-btn) .subtitle{
			color: #999999;
			font-size: 12px;
			overflow: hidden;
			white-space: normal;
		 	text-overflow: ellipsis;
		 	line-height: 22px;
		}
		/*.subtitle .right-span{
			margin-left: 10px;
		}*/
		.subtitle-red{
			color: #e10d20;
			font-size: 14px;
			margin: 0;
		}
		.cell-btn{
			font-size: 12px;
		    font-weight: 400;
		    line-height: 1.2;
		    padding: 4px 6px;
		    border-color: #1da4e8;
		    background-color: #1da4e8;
		    color: white;
		    width: 70px;
		}	
		.cell-btn:enabled:active{
			background-color: #2db4f8;
		}
		.bottom-content .cell-content-left{
			padding-right: 68px;
			float: left;
		}
		.bottom-content .cell-content-right{
			padding-top: 10px;
			width: 68px;
			height: 42px;
			float: right;
			position: absolute;
			right: 10px; 
			top: 50px;
		}
		.button-super-div{
			padding: 2px 0;
		}
		.course-status-tag{
			position: absolute;
			top: 10px;
			left: 10px;
			font-size: 12px;
			color: white;
			padding: 2px 4px;
			line-height:1em;
		}
		.course-status-tag-red{
			background-color: #EC1A2B;
		}
		.course-status-tag-green{
			background-color: #1DBF53;
		}
		.tag-img{
			width: 12px;
			height: 12px;
			margin-right: 4px;
		}
		.cell-btn{
			margin-right: 10px;
		}
		.info-span{
			margin-right: 10px;
		}
		.rmb-span{
			color: #f60009;
		}
		.cell-btn-disabled{
			border-color: #d9d9d9;
			background-color: #d9d9d9;
		}
		.cell-btn-disabled:enabled:active{
			border-color: #d9d9d9;
			background-color: #d9d9d9;
		}
		.rotation-div{
			width: 100%;
			/*min-height: 190px;*/
			height: 56vw;
			background-image: url(../../image/course_placehoder.png);
			background-size: 100% 100%;
			display: block;
		    object-fit: cover;
		}
		.rotation-img{
			width: 100%;
			/*min-height: 190px;*/
			height: 56vw;
			background-image: url(../../image/course_placehoder.png);
			background-size: 100% 100%;
			display: block;
		    object-fit: cover;
		}
		.base_left_item{
			position: fixed;
			top: 22px;
			left: 0;
			z-index: 10;
		}
		.mui-slider-indicator .mui-indicator{
			background-color: #e6e3e3;
		}
		.mui-slider-indicator .mui-active.mui-indicator{
			background-color: #ffffff;
		}
		.mui-card {
			overflow: hidden;
			margin: 0;
			border: 1px solid #bdbdbd;
			border-radius: 6px;
			background-color: #fff;
			background-clip: padding-box;
		}
		
		.train-div {
			padding-bottom: 8px;
			background-color: #f3f5f7;
		}
		.train-top-image{
			width: 100%;
			/*min-height: 190px;*/
			height: 56vw;
			background-image: url(../../image/course_placehoder.png);
			display: block;
		    object-fit: cover;
		}
		.train-image{
			width: 40px;
			height: 40px;
			float: right;
			background-image: url(../../image/course_placehoder.png);
		}
		.train-title{
			overflow: hidden;
		 	text-overflow: ellipsis;
		 	display: -webkit-box;
		 	-webkit-line-clamp: 2;
		 	-webkit-box-orient: vertical;
		 	padding-right: 10px;
		}
		.train-cell{
			padding: 10px 10px;
		}
		.sub-div{
			vertical-align:middle;
			display:table-cell;
		}
		.father-div{
			display:table;
			height: 40px;
		}
		.train-cell-content-div .train-top-title{
			/*top: 172px;*/
			bottom: 36px;
		}
		.train-top-title{
			position: absolute;
			/*top: 142px;*/
			bottom: 14px;
			left: 10px;
			font-size: 14px;
			color: white;
			padding: 6px 10px;
			line-height: 1.2em;
			background-color: rgba(0,0,0,0.5);
			text-align: center;
			width:calc(100% - 20px);
			overflow: hidden;
		 	text-overflow: ellipsis;
		 	white-space: nowrap;
		}
		.course-div{
			/*margin-top: 6px;*/
			background-color: white;
		}
		.course-top-title{
			padding: 20px;
			padding-bottom: 10px;
			line-height: 1em;
			text-align: center;
			margin: 0;
		}
		.dian-tag{
			text-decoration: underline;
		}
		.mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active{
		    color: #18b4ed;
		    border-bottom: 2px solid #18b4ed;
		}
		.gary-div{
			height: 8px;
			background-color: #f3f5f7;
		}
		.train-cell-top-div{
			height: 30px;
		}
		.train-top-tag{
			background-size: 14px;
			background-image: url(../../image/icon_train_start.png);
			background-position: center left;
			background-repeat: no-repeat;
			padding-left: 18px;
			font-size: 12px;
			color: #22a02b;
			height: 20px;
			position: absolute;
			right: 10px;
		}
		.train-top-tag-end{
			background-image: url(../../image/icon_train_end.png);
			color: #fa0009;
		}
		.train-bottom-left-title{
			/*width: 180px;*/
		}
		.train-bottom-right-title{
			max-width: calc(100% - 200px);
			float: right;
		}
		.tabbar {
			height: 40px;
			line-height: 40px;
			text-align: center;
			/*border-bottom: 1px solid #e0e0e0;*/
			background: #fff;
		}
		.tabbar .col {
			font-size: 16px;
		}
		.row {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
		}
		.col {
			-webkit-box-flex: 1;
			-webkit-flex: 1;
			flex: 1;
			position: relative;
			overflow: hidden;
		}
		.indicator-super-div{
			width: 100%;
			height: 2px;
			padding: 0 20%;
			overflow: hidden;
		}
		.indicator {
			height: 2px;
			width: 62%;
			background: #18b4ed;
			position: absolute;
			bottom: 0;
			z-index: 2;
		}
		.weui_tabbar {
			width: 100%;
			position: fixed;
			left: 0;
			bottom: 0;
		}
		.base_back_icon {
		    height: 30px; 
		    position: absolute;
		    top: 7px;
		    left: 7px;
		    margin-top: 0;
		}
		.hot-news-title{
			padding: 10px;
			background: white;
			height: 40px;
		}
		.hot-news-title-img{
			width: 14px;
			position: relative;
			top: 2px;
		}
		.hot-news-title-span{
			line-height: 20px;
		}
		.hot-train-image{
			width: 120px;
			height: 74px;
			float: right;
			border-radius: 4px;
			background-image: url(../../image/course_placehoder.png);
			display: block;
		    object-fit: cover;
		}
		.hot-train-title-div{

		}
		.hot-train-time{
			margin-top: 10px;
		}
	</style>
</head>
<body>
	<a class="base_left_item" href="#" onclick="backClick()">
        <img class="base_back_icon" src="../../image/icon_bgback.png" alt="">
    </a>
	<div name="conten_div">
		<!-- 轮播图 -->
		<div id="train_slider" class="mui-slider rotation-div" >
			<div id="rotation" class="mui-slider-group mui-slider-loop">
				<!-- <div class="mui-slider-item mui-slider-item-duplicate">
					<a href="#">
						<img class="rotation-img" src="../../image/course_placehoder.png">
					</a>
				</div>
				<div class="mui-slider-item">
					<a href="#">
						<img class="rotation-img" src="../../image/course_placehoder.png">
					</a>
				</div>
				<div class="mui-slider-item mui-slider-item-duplicate">
					<a href="#">
						<img class="rotation-img" src="../../image/course_placehoder.png">
					</a>
				</div> -->
			</div>
			<div id="noRotation" hidden="hidden">
				<div class="rotation-cell">
					<!-- <a href="#"> -->
						<img class="rotation-img" style="display: block;" src="../../image/firstNewsTitls2.png">
					<!-- </a> -->
				</div>
			</div>
			<div id="pageControl" class="mui-slider-indicator">
				<!-- <div class="mui-indicator mui-active"></div> -->
			</div> 
		</div>
		<!-- 培训动态 -->
		<!-- <div name="train_dongtai" class="train-dongtai-content">
			<div class="train-tag">
				<span class="base_black_grey base_title_font">
					培训动态
				</span>
				<span id="more_train" onclick="moreDongTai()" class="train-more base_grey base_tag_font" hidden="hidden">
					更多 »
				</span>
			</div>
			<ul id="dong_tai_list" class="mui-table-view">
			</ul>
		</div> -->
		<div class="hot-news-title">
			<img src="../../image/icon_ews.png" alt="" class="hot-news-title-img">
			<span class="base_dark_grey_shallow base_content_font hot-news-title-span">
				热门资讯
			</span>
			<span id="more_train" onclick="moreDongTai()" class="train-more base_grey base_tag_font">
				更多 »
			</span>
		</div>
		<div class="train-div mui-table-view">
			<ul id="dong_tai_list" class="mui-table-view">
				<!-- <li class="mui-table-view-cell train-cell">
					<img class="hot-train-image" src="../../image/course_placehoder.png">
					<div class="hot-train-title-div">
						<p class="base_black_grey base_title_font train-title">
							就业推荐 汇聚各路英才
							就业推荐 汇聚各路英才
							就业推荐 汇聚各路英才
							就业推荐 汇聚各路英才
						</p>
						<p class="base_grey base_content_font hot-train-time">
							2017-09-10
						</p>
					</div>
				</li> -->
			</ul>
			<!-- <div class="mui-card">
				<ul id="dong_tai_list" class="mui-table-view"> -->
				<!-- <li class="mui-table-view-cell train-cell">
						<div>。
							<img class="train-top-image" src="../../image/course_placehoder.png">
							<p class="train-top-title">
								4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划
							</p>
						</div>
					</li>
					<li class="mui-table-view-cell train-cell">
						<img class="train-image" src="../../image/course_placehoder.png">
						<div class="father-div">
							<div class="sub-div">
								<p class="base_black_grey base_content_font train-title">
									长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题
								</p>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell train-cell">
						<img class="train-image" src="../../image/course_placehoder.png">
						<div class="father-div">
							<div class="sub-div">
								<p class="base_black_grey base_content_font train-title">
									短标题
								</p>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell train-cell">
						<img class="train-image" src="../../image/course_placehoder.png">
						<div class="father-div">
							<div class="sub-div">
								<p class="base_black_grey base_content_font train-title">
									短标题
								</p>
							</div>
						</div>
					</li> -->
				<!-- </ul>
			</div> -->
		</div>
		<!-- 近期培训 -->
		<div class="course-div">
			<p class="course-top-title base_black_grey base_title_font">
				近期
				<span class="dian-tag">
					·
				</span>
				培训
			</p>
		</div>
		<div class="new-train-content">
			<!-- <div class="train-tag">
				<span class="base_black_grey base_title_font">
					近期培训
				</span>
			</div> -->
			<div class="segment-content">
				<!-- <div id="segmentedControl" class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<a index="0" class="mui-control-item mui-active" href="#item1">全部</a>
					<a index="1" class="mui-control-item" href="#item2">进行中</a>
					<a index="2" class="mui-control-item" href="#item3">已结束</a>
				</div> -->
				<div id="selectBar" class="row hightitem tabbar" >
					<div class="col base_dark_grey base_content_font" id="col1" tapmode onclick="tabswitch(1)">
						全部
						<div class="indicator-super-div">
							<div class="indicator" id="indicator1"></div>
						</div>
					</div>
					<div class="col base_dark_grey base_content_font"  id="col2" tapmode onclick="tabswitch(2)">
						进行中
						<div class="indicator-super-div">
							<div class="indicator" id="indicator2"></div>
						</div>
					</div>
					<div class="col base_dark_grey base_content_font" id="col3" tapmode onclick="tabswitch(3)">
						已结束
						<div class="indicator-super-div">
							<div class="indicator" id="indicator3"></div>
						</div>
					</div>
				</div>
			</div>
			<div id="item1" class="mui-control-content mui-active">
				<ul id="list1" class="mui-table-view">
					<!-- <div class="gary-div"></div>
					<li class="mui-table-view-cell mui-media train-cell">
						<div class="train-cell-top-div">
							<span class="train-top-tag">进行中</span>
						</div>
						<div class="train-cell-content-div">
							<img class="train-top-image" src="../../image/course_placehoder.png">
							<p class="train-top-title">
								4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划
							</p>
						</div>
						<div class="train-cell-bottom-div">
							<p class="train-bottom-right-title base_grey base_tag_font">
								广西
							</p>
							<p class="train-bottom-left-title base_dark_grey base_tag_font">
								报名时间:2017.03.20-2017.05.10
							</p>
						</div>
					</li>
					<div class="gary-div"></div>
					<li class="mui-table-view-cell mui-media train-cell">
						<div class="train-cell-top-div">
							<span class="train-top-tag train-top-tag-end">已结束</span>
						</div>
						<div class="train-cell-content-div">
							<img class="train-top-image" src="../../image/course_placehoder.png">
							<p class="train-top-title">
								4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划4SEM教学培训计划
							</p>
						</div>
						<div class="train-cell-bottom-div">
							<p class="train-bottom-right-title base_grey base_tag_font">
								广西
							</p>
							<p class="train-bottom-left-title base_dark_grey base_tag_font">
								报名时间:2017.03.20-2017.05.10
							</p>
						</div>
					</li> -->
					<!-- <li class="mui-table-view-cell mui-media">
						<a href="javascript:;">
							<p class="course-status-tag course-status-tag-green">已结束</p> 
							<img class="mui-media-object mui-pull-left course-img" src="../../image/list-default.png"/>
							<div class="mui-media-body top-content">
								<p class="course_title">课程名称</p>
							</div>
							<div class="mui-media-body bottom-content">
								<div class="">
									<p class="mui-ellipsis subtitle">
										<span class="left-span info-span"><img class="tag-img" src="../../image/icon_shijian.png">2017.05.23至2017.07.23</span>
										<span class="info-span"><img class="tag-img" src="../../image/icon_location.png">青岛</span>
										<span class="right-span info-span rmb-span"><img class="tag-img" src="../../image/icon_rmb.png">2000</span>
									</p>
								</div>
								<div class="button-super-div">
									<button type="button" class="mui-btn cell-btn">
										我要报名
									</button>
								</div>
							</div>
						</a>
					</li> -->
				</ul>
				<div class="noSign" hidden="hidden" id="noData1">
					<img src="../../image/icon_img.png" width="60%">
					<p class="font16 top_15 base_dark_grey" >
						暂无数据
					</p>
				</div>
				<div class="loadFailure" hidden="hidden" id="noNet1">
					<img src="../../image/icon_img01.png" width="60%">
					<p class="" >
						数据加载失败
					</p>
					<p>
						请检查您的网络
					</p>
					<button type="button" class="mui-btn mui-btn-outlined" onclick="refreshData()">
						重新加载
					</button>
				</div>
			</div>
			<div id="item2" class="mui-control-content">
				<ul id="list2" class="mui-table-view">
					<!-- <li class="mui-table-view-cell mui-media">
						<a href="javascript:;">
							<p class="course-status-tag course-status-tag-green">已结束</p> 
							<img class="mui-media-object mui-pull-left course-img" src="../../image/list-default.png"/>
							<div class="mui-media-body top-content">
								<p class="course_title">课程名称</p>
							</div>
							<div class="mui-media-body bottom-content">
								<div class="">
									<p class="mui-ellipsis subtitle">
										<span class="left-span info-span"><img class="tag-img" src="../../image/icon_shijian.png">2017.05.23至2017.07.23</span>
										<span class="info-span"><img class="tag-img" src="../../image/icon_location.png">青岛</span>
										<span class="right-span info-span rmb-span"><img class="tag-img" src="../../image/icon_rmb.png">2000</span>
									</p>
								</div>
								<div class="button-super-div">
									<button type="button" class="mui-btn cell-btn cell-btn-disabled">
										已报名
									</button>
								</div>
							</div>
						</a>
					</li> -->
				</ul>
				<div class="noSign" hidden="hidden" id="noData2">
					<img src="../../image/icon_img.png" width="60%">
					<p class="font16 top_15 base_dark_grey" >
						暂无数据
					</p>
				</div>
				<div class="loadFailure" hidden="hidden" id="noNet2">
					<img src="../../image/icon_img01.png" width="60%">
					<p class="" >
						数据加载失败
					</p>
					<p>
						请检查您的网络
					</p>
					<button type="button" class="mui-btn mui-btn-outlined" onclick="refreshData()">
						重新加载
					</button>
				</div>
			</div>
			<div id="item3" class="mui-control-content">
				<ul id="list3" class="mui-table-view">
				</ul>
				<div class="noSign" hidden="hidden" id="noData3">
					<img src="../../image/icon_img.png" width="60%">
					<p class="font16 top_15 base_dark_grey" >
						暂无数据
					</p>
				</div>
				<div class="loadFailure" hidden="hidden" id="noNet3">
					<img src="../../image/icon_img01.png" width="60%">
					<p class="" >
						数据加载失败
					</p>
					<p>
						请检查您的网络
					</p>
					<button type="button" class="mui-btn mui-btn-outlined" onclick="refreshData()">
						重新加载
					</button>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/timeStampTool.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
	mui.init({});
</script>
<script type="text/javascript">
	var rotationArr = new Array();//轮播图数据
	var dongtaiArr = new Array();//动态数据
	var trainStatus = 0;//近期培训状态 0:全部 1:进行中 2:已结束
	var page0 = 1;//全部分页
	var page1 = 1;//进行中分页
	var page2 = 1;//已结束分页
	var rows = 10;
	var dropRefreshCount0 = 0;
	var dropRefreshCount1 = 0;
	var dropRefreshCount2 = 0;
	var trainsArr0 = new Array();
	var trainsArr1 = new Array();
	var trainsArr2 = new Array();
	var uid;
    var jid;
	apiready = function(){
		SendBehaviorTrajectoriesNotifi1('0', '培训首页', '139','widget://index.html', '老师端首页', 'widget://html/Teacher_Teach/Teacher_TrainListWin.html', '培训frame');
		prepareData();
		setupTrainStatus();
		setPullUpRefresh();
		loadData();
		tabswitch(1);
	}  
	function tabswitch(index){
		$('.indicator').attr('style','display:none;');
		$('.col').attr('style', 'color:#323232;');
		$('#col'+index).attr('style','color:#18b4ed;');
		$('#indicator'+index).attr('style','display:block;');
		$('.mui-control-content').removeClass('mui-active');
		$('#item'+index).addClass('mui-active');
	}
	function prepareData(){
        uid = $api.getStorage('cfnetppuid');
        jid = $api.getStorage('cfnetppjxid');
        if (jid == null || jid == undefined) {
            jid = '158';
        }
    }
    function refreshData(){
    	loadJinQiTrainData();
    }
	function loadData(){
		loadRotationData();
		loadDongTaiData();
		loadJinQiTrainData();
		//默认加载后进行中和已结束
		loadJinQiTrainData1();
		loadJinQiTrainData2();
	}
	// 上拉加载
	function setPullUpRefresh() {
		api.addEventListener({
			name : 'scrolltobottom'
		}, function(ret, err) {
			if (trainStatus == 0) {//全部
				if (dropRefreshCount0 >= rows) {
					dropRefreshCount0 = 0;//防止跳页刷新
					page0++;
					loadJinQiTrainData();
				}
			}else if(trainStatus == 1){//进行中
				if (dropRefreshCount1 >= rows) {
					dropRefreshCount1 = 0;//防止跳页刷新
					page1++;
					loadJinQiTrainData();
				}
			}else{//已结束
				if (dropRefreshCount2 >= rows) {
					dropRefreshCount2 = 0;//防止跳页刷新
					page1++;
					loadJinQiTrainData();
				}
			}
		});
	}
	//设置近期培训状态
	function setupTrainStatus(){
		mui(".mui-segmented-control").on('tap','.mui-control-item',function(){
			trainStatus = this.getAttribute("index");
			if (trainStatus == 1) {
				if (trainsArr1.length == 0) {
					loadJinQiTrainData();
				}
			}else if(trainStatus == 2){
				if (trainsArr2.length == 0) {
					loadJinQiTrainData();
				}
			}
		});
	}
	//加载近期培训数据
	function loadJinQiTrainData(){
		var page = page0;//默认全部
		var currentStatus = trainStatus;
		if (currentStatus == 1) {//进行中
			page = page1;
		}else if(currentStatus == 2){//已结束
			page = page2;
		}
		var params = {
			uid : uid,
			jid : jid,
			// uid : '30412',
			// jid : '158',
			status : currentStatus,
			page : page,
			rows : rows
		};
		// alert('url:'+url_trainList+'\n'+JSON.stringify(params));
		cfnetppPOST(url_trainList, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var trains = data.data.trains;
					if (trains != undefined && trains != null && trains.constructor == Array && trains.length > 0) {
						multiplePicturesCache({
							picArr : trains,
							picKey : 'imgurl'
						}, function(imageArr){
							setupJinQiTrainData(currentStatus, imageArr);
						});
						$('#noData1').hide();
						$('#noNet1').hide();
						$('#noData2').hide();
						$('#noNet2').hide();
						$('#noData3').hide();
						$('#noNet3').hide();
					}else{
						if (page == 1) {
							if (currentStatus == 0) {//进行中
								$('#noData1').show();
								$('#noNet1').hide();
							}else if(currentStatus == 1){//已结束
								$('#noData2').show();
								$('#noNet2').hide();
							}else{//全部
								$('#noData3').show();
								$('#noNet3').hide();
							}
						}
					}
				}else{
					if (page == 1) {
						if (currentStatus == 0) {//进行中
							$('#noData1').show();
							$('#noNet1').hide();
						}else if(currentStatus == 1){//已结束
							$('#noData2').show();
							$('#noNet2').hide();
						}else{//全部
							$('#noData3').show();
							$('#noNet3').hide();
						}
					}
				}
			}else{
				//如果因为网络原因则回退page，以便于用户二次刷新
				if (page > 1) {
					if (currentStatus == 1) {//进行中
						page1--;
						dropRefreshCount1 = rows;
					}else if(currentStatus == 2){//已结束
						page2--;
						dropRefreshCount2 = rows;
					}else{//全部
						page0--;
						dropRefreshCount0 = rows;
					}
				}
				if (page == 1) {
					if (currentStatus == 0) {
						$('#noData1').hide();
						$('#noNet1').show();
					}else if(currentStatus == 1){
						$('#noData2').hide();
						$('#noNet2').show();
					}else{//全部
						$('#noData3').hide();
						$('#noNet3').show();
					}
				}
			}
		});
	}
	function loadJinQiTrainData1(){
		var currentStatus = 1;
		var params = {
			uid : uid,
			jid : jid,
			status : currentStatus,
			page : page1,
			rows : rows
		};
		cfnetppPOST(url_trainList, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var trains = data.data.trains;
					if (trains != undefined && trains != null && trains.constructor == Array && trains.length > 0) {
						multiplePicturesCache({
							picArr : trains,
							picKey : 'imgurl'
						}, function(imageArr){
							setupJinQiTrainData(currentStatus, imageArr);
						});
						$('#noData2').hide();
						$('#noNet2').hide();
					}else{
						if (page1 == 1) {
							$('#noData2').show();
							$('#noNet2').hide();
						}
					}
				}else{
					if (page1 == 1) {
						$('#noData2').show();
						$('#noNet2').hide();
					}
				}
			}else{
				//如果因为网络原因则回退page，以便于用户二次刷新
				if (page1 > 1) {
					page1--;
					dropRefreshCount1 = rows;
				}
				if (page1 == 1) {
					$('#noData2').hide();
					$('#noNet2').show();
				}
			}
		});
	}
	function loadJinQiTrainData2(){
		var currentStatus = 2;
		var params = {
			uid : uid,
			jid : jid,
			status : currentStatus,
			page : page2,
			rows : rows
		};
		cfnetppPOST(url_trainList, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var trains = data.data.trains;
					if (trains != undefined && trains != null && trains.constructor == Array && trains.length > 0) {
						multiplePicturesCache({
							picArr : trains,
							picKey : 'imgurl'
						}, function(imageArr){
							setupJinQiTrainData(currentStatus, imageArr);
						});
						$('#noData3').hide();
						$('#noNet3').hide();
					}else{
						if (page2 == 1) {
							$('#noData3').show();
							$('#noNet3').hide();
						}
					}
				}else{
					if (page2 == 1) {
						$('#noData3').show();
						$('#noNet3').hide();
					}
				}
			}else{
				//如果因为网络原因则回退page，以便于用户二次刷新
				if (page2 > 1) {
					page2--;
					dropRefreshCount2 = rows;
				}
				if (page2 == 1) {
					$('#noData3').hide();
					$('#noNet3').show();
				}
			}
		});
	}
	//设置近期培训数据
	function setupJinQiTrainData(currentStatus, datas){
		var j = 0;
		var trainListId = 'list1';
		var className = 'train0';
		if (currentStatus == 0) {//全部
			var j = trainsArr0.length;
			trainsArr0 = trainsArr0.concat(datas);
			trainListId = 'list1';
			className = 'train0';
			dropRefreshCount0 = datas.length;
		}else if(currentStatus == 1){//进行中
			var j = trainsArr1.length;
			trainsArr1 = trainsArr1.concat(datas);
			trainListId = 'list2';
			className = 'train1';
			dropRefreshCount1 = datas.length;
		}else{//已结束
			var j = trainsArr2.length;
			trainsArr2 = trainsArr2.concat(datas);
			trainListId = 'list3';
			className = 'train2';
			dropRefreshCount2 = datas.length;
		}
		for (var i = 0; i < datas.length; i++) {
			var trainData = datas[i];
			$('#' + trainListId).append(jinQiTrainHtml(j + i, className, trainData));
		}
		jinQiTrainCellClick();
	}
	//设置近期培训点击事件
	function jinQiTrainCellClick(){
		//全部
		$('.train0').unbind('click');
		$('.train0').click(function(){
			var index = $(this).attr('index');
			var cellData = trainsArr0[parseInt(index)];
			pushToTrainDetail(cellData);
		});
		//进行中
		$('.train1').unbind('click');
		$('.train1').click(function(){
			var index = $(this).attr('index');
			var cellData = trainsArr1[parseInt(index)];
			pushToTrainDetail(cellData);
		});
		//已结束
		$('.train2').unbind('click');
		$('.train2').click(function(){
			var index = $(this).attr('index');
			var cellData = trainsArr2[parseInt(index)];
			pushToTrainDetail(cellData);
		});
	}
	//跳转至培训详情页
	function pushToTrainDetail(data){
		if (api.connectionType == "none") {
			api.toast({
			    msg: '网络异常，请检查网络！'
			});
			return;
		}
		api.openWin({useWKWebView:true,
		    name: 'Teacher_TrainDetail',
		    url: 'Teacher_TrainDetail.html',
		    pageParam: data
		});
	}
	//近期培训列表html
	function jinQiTrainHtml(index, classname, data){
		var topLeftTag = '<span class="train-top-tag">进行中</span>';
		var nowDate = Date.parse(new Date());
		var endTime = parseInt(data.stoptime) * 1000;
		if (nowDate >= endTime) {//已结束
			// topLeftTag = '<p class="course-status-tag course-status-tag-green">已结束</p>';
			topLeftTag = '<span class="train-top-tag train-top-tag-end">已结束</span>';
		}
		var imageUrl = data.imgurl;
		if (imageUrl == null || imageUrl == '' || imageUrl == undefined) {
			imageUrl = '../../image/course_placehoder.png';
		}
		// return '<li index="'+index+'" class="'+classname+' mui-table-view-cell mui-media">'+
		// 			'<a href="javascript:;">'+
		// 				topLeftTag+ 
		// 				'<img class="mui-media-object mui-pull-left course-img" src="'+imageUrl+'"/>'+
		// 				'<div class="mui-media-body top-content">'+
		// 					'<p class="course_title">'+data.title+'</p>'+
		// 				'</div>'+
		// 				'<div class="mui-media-body bottom-content">'+
		// 					'<div class="">'+
		// 						'<p class="mui-ellipsis subtitle">'+
		// 							'<span class="left-span info-span"><img class="tag-img" src="../../image/icon_shijian.png">'+timePointStringWithTimeStamp(data.begintime)+'至'+timePointStringWithTimeStamp(data.stoptime)+'</span>'+
		// 							'<span class="info-span"><img class="tag-img" src="../../image/icon_location.png">'+data.address+'</span>'+
		// 							'<span class="right-span info-span rmb-span">￥'+data.price+'</span>'+
		// 						'</p>'+
		// 					'</div>'+
		// 					// '<div class="button-super-div">'+
		// 					// 	'<button type="button" class="mui-btn cell-btn cell-btn-disabled">'+
		// 					// 		'已报名'+
		// 					// 	'</button>'+
		// 					// '</div>'+
		// 				'</div>'+
		// 			'</a>'+
		// 		'</li>';
		return	'<div class="gary-div"></div>'+
				'<li index="'+index+'" class="'+classname+' mui-table-view-cell mui-media train-cell">'+
					'<div class="train-cell-top-div">'+
						topLeftTag+
					'</div>'+
					'<div class="train-cell-content-div">'+
						'<img class="train-top-image" src="'+imageUrl+'"/>'+
						'<p class="train-top-title">'+
							data.title+
						'</p>'+
					'</div>'+
					'<div class="train-cell-bottom-div">'+
						// '<p class="train-bottom-right-title base_grey base_tag_font">'+
						// 	data.address+
						// '</p>'+
						'<p class="train-bottom-left-title base_dark_grey base_tag_font">'+
							'报名时间:'+timePointStringWithTimeStamp(data.begintime.toString())+'-'+timePointStringWithTimeStamp(data.stoptime.toString())+
						'</p>'+
					'</div>'+
				'</li>';
	}
	//加载动态数据
	function loadDongTaiData(){
		var params = {
			uid : uid,
			jid : jid,
			// uid : '30412',
			// jid : '158',
			page : 1,
			rows : 4
		};
		// alert('url:'+url_trainNews+'\n'+JSON.stringify(params));
		cfnetppPOST(url_trainNews, params, true, function(data, status){
			if (status == 'success') {
				if (data.status == true) {
					var total = data.data.total;
					if (total != undefined && total != null && total != '' && parseInt(total.toString()) > 3) {//大于三条则显示更多
						$('#more_train').show();
					}
					var trends = data.data.trends;
					if (trends != undefined && trends != null && trends.constructor == Array && trends.length > 0) {
						multiplePicturesCache({
							picArr : trends,
							picKey : 'imgurl'
						}, function(imageArr){
							dongtaiArr = imageArr;
							setupDongTaiData();
						});
					}
				}
			}
		});
	}
	//设置动态数据
	function setupDongTaiData(){
		var dongTaiHtml = '';
		for (var i = 0; i < dongtaiArr.length; i++) {
			var data = dongtaiArr[i];
			dongTaiHtml += dongTaiHtmlString(i, data);
		}
		$('#dong_tai_list').html(dongTaiHtml);
		setupDongTaiClick();
	}
	//设置动态点击事件
	function setupDongTaiClick(){
		$('.dongtai-cell').unbind('click');
		$('.dongtai-cell').click(function(){
			if (api.connectionType == "none") {
				api.toast({
				    msg: '网络异常，请检查网络！'
				});
				return;
			}
			var index = $(this).attr('index');
			var dongTaiData = dongtaiArr[parseInt(index)];
			alert("叨叨");
			api.openWin({useWKWebView:true,
			    name: 'Teacher_TrainDongTaiDetail',
			    url: 'Teacher_TrainDongTaiDetail.html',
			    pageParam: dongTaiData
			});
		});
	}
	//动态html
	function dongTaiHtmlString(index, data) {
		// alert(JSON.stringify(data));
		var imgurl = data.imgurl;
		if (imgurl == null || imgurl == '') {
			imgurl = '../../image/course_placehoder.png';
		}
		return '<li index="'+index+'" class="dongtai-cell mui-table-view-cell train-cell">'+
					'<img class="hot-train-image" src="'+imgurl+'">'+
					'<div class="hot-train-title-div">'+
						'<p class="base_black_grey base_content_font train-title">'+
							data.title+
						'</p>'+
						'<p class="base_grey base_tag_font hot-train-time">'+
							timeStringWithTimeStamp(data.ctime.toString())+
						'</p>'+
					'</div>'+
				'</li>';
		// return '<li index="'+index+'" class="dongtai-cell mui-table-view-cell">'+
		// 			'<div class="cell-right-div base_tag_font base_grey">'+
		// 				timeStringWithTimeStamp(data.ctime.toString())+
		// 			'</div>'+ 
		// 			'<div class="cell-left-div base_content_font base_dark_grey">'+
		// 				data.title+
		// 			'</div>'+
		// 		'</li>';
		if (index == 0) {
			return	'<li index="'+index+'" class="dongtai-cell mui-table-view-cell train-cell">'+
						'<div>'+
							'<img class="train-top-image" src="'+imgurl+'">'+
							'<p class="train-top-title">'+
								data.title+
							'</p>'+
						'</div>'+
					'</li>';
		}else{
			return	'<li index="'+index+'" class="dongtai-cell mui-table-view-cell train-cell">'+
						'<img class="train-image" src="'+imgurl+'">'+
						'<div class="father-div">'+
							'<div class="sub-div">'+
								'<p class="base_black_grey base_content_font train-title">'+
									data.title+
								'</p>'+
							'</div>'+
						'</div>'+
					'</li>';
		}
	}
	//加载轮播图数据
	function loadRotationData() {
		var params = {
			uid : uid,
			jid : jid
			// uid : '30412',
			// jid : '158'
		};
		// alert('url:'+url_trainRotation+'\n'+JSON.stringify(params));
		cfnetppPOST(url_trainRotation, params, true, function(data, status){
			if (status == "success") {
				if (data.status == true) {
					var news = data.data.news;
					if (news != undefined && news != null && news.constructor == Array && news.length > 0) {
						multiplePicturesCache({
							picArr : news,
							picKey : 'image',
							isOriginals : 1
						}, function(imageArr){
							rotationArr = imageArr;
							setupRotationData();
						});
					}
				}
			}
		});
	}
	//设置轮播图数据
	function setupRotationData(){
		if (rotationArr.length == 1) {
			var rotationHtml = '';
			rotationHtml = noRotationHtmlString(0, rotationArr[0]);
			$('#noRotation').html(rotationHtml);
			$('#noRotation').show();
			$('#rotation').hide();
		}else{
			var rotationHtml = '';
			//额外增加的一个节点(循环轮播：第一个节点是最后一张轮播)
			var lastIndex = rotationArr.length - 1;
			var rotationLastData = rotationArr[lastIndex];
			rotationHtml += firstLastImgHtml(lastIndex, rotationLastData);
			//遍历数组
			for (var i = 0; i < rotationArr.length; i++) {
				var rotationData = rotationArr[i];
				rotationHtml += rotationHtmlString(i, rotationData);
			}
			//额外增加的一个节点(循环轮播：最后一个节点是第一张轮播)
			var firstIndex = 0;
			var rotationFirstData = rotationArr[firstIndex];
			rotationHtml += firstLastImgHtml(firstIndex, rotationFirstData);
			//设置轮播图代码
			$('#rotation').html(rotationHtml);
			//设置page Control
			$('#pageControl').html(pageControlHtml(rotationArr.length));
			//设置自动轮播
			setupAutoRotation();
			$('#noRotation').hide();
			$('#rotation').show();
		}
		//设置轮播图点击事件
		setupRotationCellClick();
	}
	function setupRotationCellClick(){
		$('.rotation-cell').unbind('click');
		$('.rotation-cell').click(function(event) {
			if (api.connectionType == "none") {
				api.toast({
				    msg: '网络异常，请检查网络！'
				});
				return;
			}
			console.log("轮播图");
			var index = $(this).attr('index');
			var rotationData = rotationArr[parseInt(index)];
			if (rotationData.detail != null && rotationData.detail != '') {
				api.openWin({useWKWebView:true,
				    name: 'Teacher_TrainNewsDetail',
				    url: 'Teacher_TrainNewsDetail.html',
				    pageParam: rotationData
				});
			}
		});
	}
	//分页html
	function pageControlHtml(count){
		var pageControl = '';
		pageControl += '<div class="mui-indicator mui-active"></div>';
		for (var i = 1; i < count; i++) {
			pageControl += '<div class="mui-indicator"></div>';
		}
		return pageControl;
	}
	//轮播图首尾
	function firstLastImgHtml(index, data){
		return '<div index="'+index+'" class="rotation-cell mui-slider-item mui-slider-item-duplicate">'+
					'<a href="#">'+
						'<img class="rotation-img" src="'+data.image+'">'+
					'</a>'+
				'</div>';
	}
	//轮播图
	function rotationHtmlString(index, data){
		return '<div index="'+index+'" class="rotation-cell mui-slider-item">'+
					'<a href="#">'+
						'<img class="rotation-img" src="'+data.image+'">'+
					'</a>'+
				'</div>';
	}
	//不轮播的cell
	function noRotationHtmlString(index, data){
		return '<div index="'+index+'" class="rotation-cell">'+
					// '<a href="#">'+
						'<img class="rotation-img" style="display: block;" src="'+data.image+'">'+
						// '<img class="rotation-img" src="../../image/temp_train_top.png">'+
					// '</a>'+
				'</div>';
	}
	function setupAutoRotation(){
		var slider = mui("#train_slider");
		slider.slider({
			interval: 3000
		});
	}
	//更多动态
	function moreDongTai(){
		api.openWin({useWKWebView:true,
		    name: 'Teacher_TrainDongTaiListWin',
		    url: 'Teacher_TrainDongTaiListWin.html'
		});
	}
	function backClick(){
		SendBehaviorTrajectoriesNotifi1('1', '培训首页', '139','widget://index.html', '老师端首页', 'widget://html/Teacher_Teach/Teacher_TrainListWin.html', '培训frame');	
        api.closeWin();
    }
</script>
</html>